package contest1609;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class LCreateBinaryTree {
    static Scanner cin = new Scanner(new BufferedInputStream(System.in));//大量输入优化版本
    static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));//大量输出优化版本
    static PrintWriter cerr = new PrintWriter(System.err, true);//开启调试模式,一般输出量不大，不需要buffered

    public static void main(String[] args) {
        //TODO AOJ开启你的ACM传奇人生
        cerr.println("----Start your ACM legendary life with AOJ(www.webturing.com)----");
        while (cin.hasNextInt()) {
            BinaryTree.create(cin.next(), cin.next()).postVisit();
            cout.println();
        }


        cin.close();//关闭输入流
        cout.close();//关闭输出流，这是必须的，否则一般不会自动刷新缓冲区
    }

    static class BinaryTree {
        char root;
        BinaryTree left, right;

        public BinaryTree(char root) {
            this(root, null, null);

        }

        public BinaryTree(char root, BinaryTree left, BinaryTree right) {
            this.root = root;
            this.left = left;
            this.right = right;
        }

        static BinaryTree create(String pre, String mid) {
            if (pre.length() == 0) return null;
            if (pre.length() == 1) return new BinaryTree(pre.charAt(0));
            char root = pre.charAt(0);
            int pos = mid.indexOf(root);
            String leftMid = mid.substring(0, pos);
            String rightMid = mid.substring(pos + 1);
            String leftPre = pre.substring(1, pos + 1);
            String rightPre = pre.substring(pos + 1);
            BinaryTree left = create(leftPre, leftMid);
            BinaryTree right = create(rightPre, rightMid);
            return new BinaryTree(root, left, right);

        }

        void postVisit() {
            if (left != null)
                left.postVisit();
            if (right != null)
                right.postVisit();
            cout.print(root);
        }
    }
}
